package com.cloud.punish.tasklist.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cloud.punish.tasklist.service.TaskListTabFormService;
import com.cloud.punish.workflow.entity.WfActInst;
import com.cloud.punish.workflow.mapper.WfActInstMapper;

import tk.mybatis.mapper.entity.Example;

@Service
@Transactional
public class TaskListTabFormServiceImpl implements TaskListTabFormService {

	@Autowired
	private WfActInstMapper wfActInstMapper;

	@Override
	public WfActInst loadActInst(long recId, List<Long> parts) {
		Example example = new Example(WfActInst.class);
		Example.Criteria criteria = example.createCriteria();
		criteria.andEqualTo("recId", recId);
		criteria.andIn("partId", parts);
		example.orderBy("actId").desc();
		List<WfActInst> acts = wfActInstMapper.selectByExample(example);
		if (null != acts && acts.size() > 0) {
			return acts.get(0);
		}
		return null;
	}

}
